﻿using System;


using System.Text;
using IAM.Interface.Model.Interface;
using IAM.Interface.Model.ENUM;
using System.Web;

namespace IAM.Interface.Model
{
    /// <summary>
    /// 获取用户信息列表
    /// </summary>
    public class ExportData : AbstractConvertObject, IConvertXml
    {
        #region 属性
        private DateTime _exporttime = System.DateTime.Now;
        private string _appname = "";
        private ExportDataType _datatype = ExportDataType.IdentityUserList;

        /// <summary>
        /// 文件生成时间
        /// </summary>
        public DateTime ExportTime
        {
            get
            {
                return _exporttime;
            }
            set
            {
                _exporttime = value;
            }

        }
        /// <summary>
        /// 系统名称
        /// </summary>
        public string AppName
        {
            get
            {
                return _appname;
            }
            set
            {
                _appname = value;
            }

        }
        /// <summary>
        /// 数据文件交换类型
        /// </summary>
        public ExportDataType DataType
        {
            get
            {
                return _datatype;
            }
            set
            {
                _datatype = value;
            }

        }
        #endregion
        #region IConvertXml

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append("<ExportData");
                _xml.Append(" ExportTime=\"" + this.ExportTime.ToString() + "\"");
                _xml.Append(" AppName=\"" + IAM.Interface.Common.EnDeCoding.Encode(this.AppName )+ "\"");
                _xml.Append(" DataType=\"" + this.DataType.ToString() + "\"");
                _xml.Append(" >");
                return _xml.ToString();
            }


        }

        public string XMLFinis
        {
            get
            {
                return "</ExportData>";
            }
        }
        public string XML
        {
            get
            {
                return XMLBoday + XMLFinis;
            }
        }
        #endregion
        #region AbstractConvertObject
        public override object ConvertToObject()
        {
            //1.获取当前结点
            this.ExportTime = System.Convert.ToDateTime(this.CurrentXmlNode.Attributes["ExportTime"].InnerText);
            this.AppName = IAM.Interface.Common.EnDeCoding.Decode(this.CurrentXmlNode.Attributes["AppName"].InnerText);
            string strDataType = this.CurrentXmlNode.Attributes["DataType"].InnerText;
            switch (strDataType.ToLower())
            {
                case "identityuserlist":
                    this.DataType = ExportDataType.IdentityUserList;
                    break;
                case "AuditFetch":
                    this.DataType = ExportDataType.AuditFetch;
                    break;
            }

            return this;
        }
        #endregion
    }
}
